<?php
require_once("global.php");
$id = intval($id);

$sitetitle = $system["sitename".$bi];

#[设定每页显示数量]
$psize = intval($thiscate["psize"]) ? intval($thiscate["psize"]) : 30;
$pageurl = "memberlist.php?id=".$id;
#[获取分页ID]
$pageid = intval($pageid);
if($pageid < 1)
{
	$pageid = 1;
}
$offset = $pageid > 0 ? ($pageid-1)*$psize : 0;


$condition = "WHERE u.state='1' ";


if($id)
{
	
	$condition .= " and u.hangye_id = '".$id."' ";
}

if($keywords)
{	
$condition .= " and u.company like '%".$keywords."%' ";
}
$sql = "SELECT count(*) AS countid FROM ".$prefix."user AS u ".$condition;
$listcount = $DB->qgGetOne($sql);#[获取总数]
$msglistcount = $listcount["countid"];
$psize = intval($thiscate["psize"]) ? intval($thiscate["psize"]) : 30;
$pagelist = page($pageurl,$bi,$msglistcount,$psize,$pageid);#[获取分页的数组]

$sqlorder = "u.levelid asc ,u.id asc";




$sql = "SELECT u.*,h.name FROM ".$prefix."user AS u LEFT JOIN ".$prefix."hangye_cate AS h ON u.hangye_id=h.id ".$condition." ORDER BY ".$sqlorder." LIMIT ".$offset.",".$psize;

$rslist = $DB->qgGetAll($sql,true);
$msglist = array();
$i = 1;
foreach($rslist AS $key=>$value)
{

    $rsd = $DB->qgGetOne("SELECT * FROM ".$prefix."upfiles WHERE id='".$value["thumb"]."'");	#[缩略图]
    $value["filename"] = $rsd["folder"].$rsd["filename"];
	$value["thumbfile"] = $rsd["folder"].$rsd["thumbfile"];
	$msglist[] = $value;
}
unset($rslist,$msgcatelist,$msglistcount,$listcount,$sql);

$tpl_list="member.list";
FOOT($tpl_list);
?>